Improve shellescape to handle apostrophes in paths#849
Merged
lervag merged 1 commit intolervag:masterfrom May 25, 2017
Merged
Conversation
Owner
|
Thanks! I'll have to check that this does not break something. If it won't break anything, then I don't see any reason not to accept this. |
lervag
added a commit
that referenced
this pull request
May 25, 2017
Owner
|
I could not find any problems with this, and so I see no reason not to merge it. Thanks! |
Contributor
Author
|
My pleasure! |
lervag
added a commit
that referenced
this pull request
May 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I was working in a directory tree on Ubuntu that happened to have an apostrophe somewhere in its path, i.e.,
/why/would/anyone's/folders/be/named/thus.tex. vimtex failed to open the resulting pdf, so I dug a little and found that after all the shellescapes and substitutions, the viewer call looked something likeIt seems like the bad things are happening on line 57 in
autoload/vimtex/view/general.vim(and probably similar lines for the other viewers):Actually, the output of
vimtex#util#shellescape(outfile)looks OK, however the requisite escape character is removed by the outer call tosubstitute.The solution I've implemented here is to explicitly escape the escape character in
shellescape, like you're already doing on win32 systems. I haven't thought deeply about potential gotchas with this workaround, or done any tests except on this particular document, but since you're already doing this on Windows I figured it might not be too bad.Btw., I've since repented and renamed my directories in a less pathological fashion, so I don't depend on this fix myself. But in case you'd like to support these edge cases, seeing as such paths are after all valid, here's a possible fix.